home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 05 - 1989 / 05.06 Jun 89 / XCMD Code / GetFileName.c (Listing 1) next >
Encoding:
Text File  |  1989-04-11  |  1.8 KB  |  79 lines  |  [TEXT/KAHL]

  1. /********************************/
  2. /* File: GetFileName.c            */
  3. /*                                */
  4. /* Using Standard File Package    */
  5. /* query the user for the name    */
  6. /* of a file to open, and return*/
  7. /* the name along with the         */
  8. /* working directory id of the    */
  9. /* file.                        */
  10. /*                                */
  11. /* Paramters:                    */
  12. /* paramCnt = number of types    */
  13. /* params[0..3] = the types to     */
  14. /* filter for (see Inside Mac.    */
  15. /* I-523 for details            */    
  16. /* ----------------------------    */
  17. /* To Build:                    */
  18. /*                                 */
  19. /* (1) Create a project using    */
  20. /* this file as well as the     */
  21. /* XCMD.Glue.c file. (Set         */
  22. /* project type to     XCMD (or    */
  23. /* XFCN) from the Project menu.    */
  24. /*                                */
  25. /* (2) Bring the project up to    */
  26. /* date.                        */
  27. /*                                */
  28. /* (3) Build Code Resource.     */
  29. /*                                */
  30. /* (4) Use ResEdit to copy the     */
  31. /* resource to your stack.        */
  32. /********************************/
  33.  
  34. #include    <MacTypes.h>
  35. #include    <OSUtil.h>
  36. #include    <MemoryMgr.h>
  37. #include    <FileMgr.h>
  38. #include    <ResourceMgr.h>
  39. #include    <pascal.h>
  40. #include    <strings.h>
  41. #include     "HyperXCmd.h"
  42. #include    "HyperUtils.h"
  43.  
  44. pascal void main( paramPtr )
  45.     XCmdBlockPtr    paramPtr;
  46. {
  47.     short        FileWDID;
  48.     short        numTypes;
  49.     short        i;
  50.     SFTypeList    typs;
  51.     char        FileName[256];
  52.     char        WDIDString[32];
  53.     char        comma[2];
  54.     
  55.     if( !paramPtr->paramCount )
  56.         numTypes    = -1;         /* select all since no type specified */
  57.     else{
  58.         numTypes = paramPtr->paramCount;
  59.         for( i = 0; i < numTypes; i++ )
  60.             BlockMove( *(paramPtr->params[i]), &typs[i], 4L );
  61.     }
  62.     
  63.     *FileName = '\0';
  64.     
  65.     if( GetFileNameToOpen( typs, numTypes, FileName, &FileWDID ) ){
  66.         NumToStr( paramPtr, (long)FileWDID, &WDIDString );
  67.         PtoCstr( WDIDString );
  68.         
  69.         comma[0] = ',';        /* for you MPW folk */
  70.         comma[1] = '\0';
  71.         
  72.         strcat( FileName, comma );
  73.         strcat( FileName, WDIDString );
  74.         CtoPstr( FileName );
  75.     }
  76.     paramPtr->returnValue = PasToZero( paramPtr, FileName );
  77. }
  78.  
  79.